package com.example.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class ButtonEnableActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_test;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button_enable);
        Button btn_disable = findViewById(R.id.btn_disable);
        Button btn_enable = findViewById(R.id.btn_enable);
        btn_test = findViewById(R.id.btn_test);
        btn_test.setOnClickListener(this);
        btn_enable.setOnClickListener(this);
        btn_disable.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(v.getId()==R.id.btn_disable){
            //禁用按钮
            btn_test.setEnabled(false);
        }else if (v.getId() == R.id.btn_enable){
            //启用按钮
            btn_test.setEnabled(true);
        }
    }
}